package com.dhy.cli.command;

import cn.hutool.core.bean.BeanUtil;
import com.dhy.generator.MainGenerator;
import com.dhy.model.MainTemplateConfig;
import lombok.Data;
import picocli.CommandLine;
import picocli.CommandLine.Option;
import picocli.CommandLine.Command;

import java.util.concurrent.Callable;

@Data
@Command(name = "generate", description = "代码生成", mixinStandardHelpOptions = true)
public class GenerateCommand implements Callable<Integer> {

    @Option(names = {"-a", "--author"}, description = "author", interactive = true,echo = true)
    private String author = "xxx";
    @Option(names = {"-o", "--output"}, description = "outputText", interactive = true,echo = true)
    private String outputText = "输出结果";
    @Option(names = {"-l", "--loop"}, description = "loop", interactive = true,echo = true)
    private boolean loop;

    @Override
    public Integer call() throws Exception {
        MainTemplateConfig mainTemplateConfig = new MainTemplateConfig();
        BeanUtil.copyProperties(this,mainTemplateConfig);
        System.out.println("配置信息："+mainTemplateConfig);
        MainGenerator.doGenerate(mainTemplateConfig);
        return 0;
    }
}
